package day01.日期类.Acm;

import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Locale;
import java.util.Scanner;

/**
 * @author feng
 * @Date 2022/1/3 16:23
 */
public class Test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份:(2015 2)");
        int year = sc.nextInt();
        int month = sc.nextInt();
        //得到本月日期
        LocalDate dates = LocalDate.of(year, month, 1);
        int day = dates.getDayOfMonth();
        String dayofMonth = dates.getMonth().getDisplayName(TextStyle.FULL, Locale.getDefault());
        //返回当前月的天数
        int daysOfWeeks = dates.lengthOfMonth();
        //当前月第一天是周几
        int dayofWeek = dates.getDayOfWeek().getValue();
        System.out.println(year + "年" + dayofMonth);
        System.out.println("一\t二\t三\t四\t五\t六\t七\t");
        System.out.println("---------------------------");
        //输出前导空格
        for (int i = 1; i < dayofWeek; i++) {
            System.out.print("\t");
        }
        for (int i = 1; i <= daysOfWeeks; i++) {
            System.out.print(i + "\t");
            if ((dayofWeek + i-1) % 7 == 0) {
                System.out.println();
            }

        }

    }
}
